package egovframework.npqs.pqi.mobile.activity.quarantinerequest;

import java.util.HashMap;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.InputType;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
import egovframework.npqs.pqi.mobile.ActivityMain;
import egovframework.npqs.pqi.mobile.AppStatus;
import egovframework.npqs.pqi.mobile.BaseFragment;
import egovframework.npqs.pqi.mobile.R;
import egovframework.npqs.pqi.mobile.activity.ProdSearchActivity;
import egovframework.npqs.pqi.mobile.activity.disinfection.DisinfectionResultList;
import egovframework.npqs.pqi.mobile.activity.quarantineresult.QuarantineResultList;
import egovframework.npqs.pqi.mobile.common.Const;
import egovframework.npqs.pqi.mobile.jsoncontent.ErrorItem;
import egovframework.npqs.pqi.mobile.jsonparser.QuarantineRequestThread;
import egovframework.npqs.pqi.mobile.jsonparser.QuarantineRequestThread.QuarantineRequestThreadCallback;
import egovframework.npqs.pqi.mobile.util.BrUtilManager;

// 검역신청
public class QuarantineRequestList extends BaseFragment implements QuarantineRequestThreadCallback, OnClickListener, OnScrollListener{
	private View view;
	private TextView titleTxt, textCnt, navigation;
	private ImageButton menuBtn, homeBtn, searchBtn, detailSearchBtn;
	private ActivityMain am;
	
	private QuarantineRequestThread quarantineThread;
	private QuarantineListAdapter quarantineListAdapter;
	private AppStatus myapp;
	private Context context;
	private ListView listView;
	
	private Button footerBtn01, footerBtn02, footerBtn03, footerBtn04;	// 하단 버튼
	private ImageButton searchDateBtn01, searchDateBtn03, searchDateBtn07;	// 1일전, 3일전, 7일전 버튼
	private EditText sdateEdit, edateEdit, placeEdit, inOutEdit, detailOffCdEdit, detailRequestNumEdit; //시작날자, 끝날짜, 검역장소, 수출입업체, 검역신청번호 앞 2자리, 검역신청번호 뒷자리
	private RadioButton userChk, userAllChk;	// 라디오 버튼
	
	private LinearLayout hdLinearLayout; 
	private LinearLayout black_layout;
	
	private EditText offCdEdit, requestNumEdit, edit_bl_no, edit_hwa_no;
	private ImageButton sCalenderBtn, eCalenderBtn;
	private boolean searchState;	// 상세 검색인지 구분하는 값
	private boolean pageState;	// 페이징을 구분하는 값
	
	private int mPageCnt = 1;	// 현재 페이지 수
	private int nTotCnt = 0;	// 리스트 카운트 수
	private String trnNm;	//수출, 수입 구분
	
	// 호출 결과값 저장
    private String mResult;
	
	private final static int MSG_QUARANTINE_COMPLETED = 0;
	private final static int MSG_QUARANTINE_ERROR = 1;
	private final static int MSG_NETWORK_ERROR = 2;
	
	HashMap<String,String>	searchMap;
    private String temp;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		AppStatus.navigation.addPathLocation("검역신청");
		if (view != null) {
			ViewGroup parent = (ViewGroup) view.getParent();
			if (parent != null)
				parent.removeView(view);
		} else {
			view = inflater.inflate(R.layout.fragment_list, container, false);
			trnNm="";
			searchMap = new HashMap<String,String>();
			init();
		}
		return view;
	}
	
	private void init(){
		context = view.getContext();
		myapp = (AppStatus) context.getApplicationContext();
		myapp.startBroker(context);
		am = (ActivityMain) ActivityMain.am;
		searchState = true;
		
		offCdEdit = (EditText)view.findViewById(R.id.edit_offcd);
		requestNumEdit = (EditText)view.findViewById(R.id.edit_request_num);

		offCdEdit.setText(myapp.getLoginItem().getOffCd());

		hdLinearLayout =(LinearLayout)view.findViewById(R.id.search_hd_layout);
		black_layout = (LinearLayout)view.findViewById(R.id.black_layout);

		Paint paint = new Paint();
		paint.setColor(Color.BLACK);
		paint.setAlpha(70);
		black_layout.setBackgroundColor(paint.getColor());

		listView = (ListView)view.findViewById(R.id.quarantine_list);
		listView.setOnScrollListener(this);
		quarantineListAdapter = new QuarantineListAdapter();

		homeBtn = (ImageButton)view.findViewById(R.id.btnHome);
		homeBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				getActivity().onBackPressed();
			}
		});
		menuBtn = (ImageButton)view.findViewById(R.id.btnLeftMenu);
		menuBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				am.toggle();
			}
		});

		searchBtn = (ImageButton)view.findViewById(R.id.search_btn);
		searchBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				myapp.utilm.InputKeybordHidden(context, requestNumEdit);
				searchState = true;
				pageState = false;
				mPageCnt =1;
				searchList();
			}
		});

		detailSearchBtn = (ImageButton)view.findViewById(R.id.search_detail_btn);
		detailSearchBtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				myapp.utilm.InputKeybordHidden(context, placeEdit);
				myapp.utilm.InputKeybordHidden(context, inOutEdit);
				myapp.utilm.InputKeybordHidden(context, detailRequestNumEdit);
				searchState = false;
				pageState = false;
				mPageCnt =1;
				searchList();
			}
		});

		textCnt = (TextView)view.findViewById(R.id.text_cnt);
		titleTxt = (TextView)view.findViewById(R.id.headerTitleText);
		titleTxt.setText("검역신청");
		
		navigation = (TextView)view.findViewById(R.id.navigation);
		navigation.setText(AppStatus.navigation.getPath());
		
		userChk =(RadioButton)view.findViewById(R.id.chk_user);
		userAllChk =(RadioButton)view.findViewById(R.id.chk_all_user);

		userChk.setText(myapp.getLoginItem().getUserNm());

		userAllChk.setChecked(true);	// 로드될때 전체에 체크가 되있게 한다.

		sdateEdit = (EditText)view.findViewById(R.id.edit_sdate);	// 시작일자 에디트 박스
		edateEdit = (EditText)view.findViewById(R.id.edit_edate);	// 종료일자 에디트 박스

		sdateEdit.setText(BrUtilManager.getCurrentDateTime(0));
		edateEdit.setText(BrUtilManager.getCurrentDateTime(0));

		sCalenderBtn = (ImageButton)view.findViewById(R.id.btn_s_calender);
		eCalenderBtn = (ImageButton)view.findViewById(R.id.btn_e_calender);

		sCalenderBtn.setOnClickListener(this);
		eCalenderBtn.setOnClickListener(this);

		sdateEdit.setInputType(InputType.TYPE_NULL);
		edateEdit.setInputType(InputType.TYPE_NULL);

		placeEdit = (EditText)view.findViewById(R.id.edit_place);	// 검역장소 에디트 박스
		inOutEdit = (EditText)view.findViewById(R.id.edit_in_out);	// 수출입업체 에디트 박스

		edit_bl_no = (EditText)view.findViewById(R.id.edit_bl_no);		//bl번호
		edit_hwa_no = (EditText)view.findViewById(R.id.edit_hwa_no);	//화물관리번호

		detailOffCdEdit = (EditText)view.findViewById(R.id.edit_detail_offcd);
		detailOffCdEdit.setText(myapp.getLoginItem().getOffCd());

		detailRequestNumEdit = (EditText)view.findViewById(R.id.edit_detail_request_no);

		footerBtn01 = (Button)view.findViewById(R.id.footer01Btn);
		footerBtn02 = (Button)view.findViewById(R.id.footer02Btn);
		footerBtn03 = (Button)view.findViewById(R.id.footer03Btn);
		footerBtn04 = (Button)view.findViewById(R.id.footer04Btn);

		searchDateBtn01 = (ImageButton)view.findViewById(R.id.btn_oneday);
		searchDateBtn03 = (ImageButton)view.findViewById(R.id.btn_threeday);
		searchDateBtn07 = (ImageButton)view.findViewById(R.id.btn_sevenday);

		footerBtn01.setOnClickListener(this);
		footerBtn02.setOnClickListener(this);
		footerBtn03.setOnClickListener(this);
		footerBtn04.setOnClickListener(this);

		searchDateBtn01.setOnClickListener(this);
		searchDateBtn03.setOnClickListener(this);
		searchDateBtn07.setOnClickListener(this);

		firstDataLoad();

	}
	
	private void searchClear(){
		if(searchState){
			sdateEdit.setText(BrUtilManager.getCurrentDateTime(0));
			edateEdit.setText(BrUtilManager.getCurrentDateTime(0));
			userChk.setChecked(false);
			userAllChk.setChecked(true);
			placeEdit.setText("");
			inOutEdit.setText("");
			detailRequestNumEdit.setText("");
			searchDateBtn01.setBackgroundResource(R.drawable.btn_oneday_off);
			searchDateBtn03.setBackgroundResource(R.drawable.btn_threeday_off);
			searchDateBtn07.setBackgroundResource(R.drawable.btn_sevenday_off);
		}else{
			requestNumEdit.setText("");
		}
	}
	
	private void searchList(){	//조건검색
		
		/*if(!myapp.utilm.dateCheck(sdateEdit.getText().toString(), edateEdit.getText().toString())){	// 종료일자가 더 클경우
			myapp.utilm.ShowDialog(context, "오류", "종료일자가 시작일자보다 빠릅니다.", 20);
			return;
		}*/
		
		myapp.showDialogNo(context);
		
		searchMap.put(Const.SEARCHOFFCD, offCdEdit.getText().toString());
		searchMap.put(Const.SEARCHSDATE, sdateEdit.getText().toString());
		searchMap.put(Const.SEARCHEDATE, edateEdit.getText().toString());
		searchMap.put(Const.TARGETPAGE, ""+mPageCnt);
		
		if(searchState){
			if(offCdEdit.getText().toString().equals("")){	// offcd가 비어있을 경우
				myapp.utilm.ShowDialog(context, "오류", "검역신청번호를 입력해 주세요.", 20);
				return;
			}
			
			searchMap.put(Const.SEARCHRECNO, requestNumEdit.getText().toString());
			searchMap.put(Const.SEARCHUSERSN, "");
			searchMap.put(Const.SEARCHINSPLACE, "");
			searchMap.put(Const.SEARCHVENNM, "");
			searchMap.put(Const.SEARCHBLNO, "");
			searchMap.put(Const.SEARCHHWANO, "");
		}else{
			searchMap.put(Const.SEARCHRECNO, detailRequestNumEdit.getText().toString());
			
			if(userChk.isChecked()){
				searchMap.put(Const.SEARCHUSERSN, myapp.getLoginItem().getUserSn());
			}else{
				searchMap.put(Const.SEARCHUSERSN, "");			
			}

			searchMap.put(Const.SEARCHINSPLACE, placeEdit.getText().toString());
			searchMap.put(Const.SEARCHVENNM, inOutEdit.getText().toString());
			//품목저장값
			searchMap.put(Const.SEARCHBLNO, edit_bl_no.getText().toString());		//BL번호
			searchMap.put(Const.SEARCHHWANO, edit_hwa_no.getText().toString());		//화물관리번호
		}
		
		Log.i("검색 상태 값","검색 상태 값 = " + searchState);
		Log.i("페이지 상태 값","페이지 상태 값 = " + pageState);
		Log.i("페이지 상태 값","현재 페이지 수  = " + mPageCnt);
		
		temp = "조건검색";
		threadStart();
		searchClear();
	}
	
	private void firstDataLoad(){
		myapp.showDialogNo(context);
		temp = "처음검색";
		threadStart();
	}
	
	public void threadStart(){
		if("조건검색".equals(temp)){
    		quarantineThread = new QuarantineRequestThread(context, this, searchMap, pageState, AppStatus.getmUserId());
			quarantineThread.start();
    	}
    	if("처음검색".equals(temp)){
    		quarantineThread = new QuarantineRequestThread(context, this, myapp.getLoginItem().getOffCd(), AppStatus.getmUserId());
			quarantineThread.start();
    	}
	}
	
	@Override
	public void OnQuarantineRequestCompleted(boolean isNetworkConntected,
			boolean results, String message) {
		if(null != message && !"".equals(message)){
			mResult = message;
			reesultToast();
		}
		
		if(myapp.dialog !=null && myapp.dialog.isShowing()) {
			myapp.dialog.dismiss();
		}
		
		if(!isNetworkConntected){	// 네트워크 접속이 되어 있지 않을 때
			Message msg = handler.obtainMessage();
			msg.what = MSG_NETWORK_ERROR;
			handler.sendMessage(msg);
			return;
		}
		
		if(results) {
			Message msg = handler.obtainMessage();
			msg.what = MSG_QUARANTINE_COMPLETED;
			handler.sendMessage(msg);
		}
	}

	@Override
	public void OnQuarantineRequestError(ErrorItem errorItem) {
		if(myapp.dialog !=null && myapp.dialog.isShowing()) {
			myapp.dialog.dismiss();
		}

		Message msg = handler.obtainMessage();
		msg.what = MSG_QUARANTINE_ERROR;
		if(errorItem != null) {
			msg.obj = errorItem.getrDesc();
		}
		handler.sendMessage(msg);
		
	}
	
	private Handler handler = new Handler() {
		@Override
		public void handleMessage(final Message msg) {
			switch (msg.what) {
			case MSG_QUARANTINE_COMPLETED:
				layoutHidden(true);	// 일반 검색 or 상세 검색 으로 검색 했을 때 상세 검색 창은 닫는다.
				
				nTotCnt = Integer.parseInt(myapp.getArrQuarantineItem().get(0).getTotalRows());
				textCnt.setText("총 "+nTotCnt+"건이 조회되었습니다.");
				quarantineListAdapter.notifyDataSetChanged();
				listView.setAdapter(quarantineListAdapter);	
				
				if(pageState) listView.setSelection(listView.getCount()- 17);
				
				pageState = false;
				break;

			case MSG_QUARANTINE_ERROR:
				String errMsg = "";
				if(msg == null ||msg.obj.toString().equals("")){
					errMsg = "서버와의 연결에 실패하였습니다.";
				}else{
					errMsg = msg.obj.toString();	
				}
				layoutHidden(true);	// 일반 검색 or 상세 검색 으로 검색 했을 때 상세 검색 창은 닫는다.
				
				textCnt.setText("데이터가 존재하지 않습니다.");
				quarantineListAdapter.notifyDataSetChanged();
				listView.setAdapter(quarantineListAdapter);
				if(!pageState){
					myapp.utilm.ShowDialog(context, "실패", errMsg, 20);
				}
				
				pageState = false;
				break;

			case MSG_NETWORK_ERROR:
				myapp.utilm.ShowDialog(context, "실패", "네트워크에러", 20);

			default:
				break;
			}
		}
	};
	
	class QuarantineListAdapter extends BaseAdapter {
		TextView txt_request_no, txt_request_date;
		TextView txt_ven_name, txt_nat_name;
		TextView txt_prod_name, txt_ins_place;

		@Override
		public int getCount() {
			return myapp.getArrQuarantineItem().size();
		}

		@Override
		public Object getItem(int position) {
			return myapp.getArrQuarantineItem().get(position);
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(final int position, View convertView, ViewGroup parent) {
			if (convertView == null || convertView != null) {
    			LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    			convertView = inflater.inflate(R.layout.list_item, parent, false);
    		}
			
			txt_request_no = (TextView)convertView.findViewById(R.id.txt_request_no);
			txt_request_date = (TextView)convertView.findViewById(R.id.txt_request_date);
			txt_ven_name = (TextView)convertView.findViewById(R.id.txt_ven_name);
			txt_nat_name = (TextView)convertView.findViewById(R.id.txt_nat_name);
			txt_prod_name = (TextView)convertView.findViewById(R.id.txt_prod_name);
			txt_ins_place = (TextView)convertView.findViewById(R.id.txt_ins_place);
			
			txt_request_no.setText(myapp.getArrQuarantineItem().get(position).getOffCd() + "-" +myapp.getArrQuarantineItem().get(position).getRecNo());
			txt_request_date.setText(myapp.getArrQuarantineItem().get(position).getTraDe());
			txt_ven_name.setText(myapp.getArrQuarantineItem().get(position).getVenNm());
			txt_nat_name.setText(myapp.getArrQuarantineItem().get(position).getNatNm());
			txt_prod_name.setText(myapp.getArrQuarantineItem().get(position).getPrdlstNm());
			if(myapp.getArrQuarantineItem().get(position).getTrnCd().equals("173003")||myapp.getArrQuarantineItem().get(position).getTrnCd().equals("173004")){
				trnNm="수입";
			}else if(myapp.getArrQuarantineItem().get(position).getTrnCd().equals("173001")||myapp.getArrQuarantineItem().get(position).getTrnCd().equals("173002")){
				trnNm="수출";
			}
			txt_ins_place.setText(trnNm);
			
			convertView.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					listItemClickEvent(position);
				}
			});
			
			return convertView;
		}
		
		private void listItemClickEvent(final int position) {
			Intent intent = new Intent(getActivity().getApplication(), QuarantineRequestDetailActivity.class);
			intent.putExtra("recNo", myapp.getArrQuarantineItem().get(position).getRecNo());
			startActivity(intent);
		}
	}
	
	private void layoutHidden(boolean state){
		if(state){	//	검색 모드가 아닐 때
			hdLinearLayout.setVisibility(View.GONE);
			black_layout.setVisibility(View.GONE);
			footerBtn01.setBackgroundResource(R.drawable.f_search_sel);
		
		}else{	// 상세 검색 일 때
			hdLinearLayout.setVisibility(View.VISIBLE);
			black_layout.setVisibility(View.VISIBLE);
			footerBtn01.setBackgroundResource(R.drawable.f_search);
		}
	}
	
	private void sDateSetting(){
		String str = sdateEdit.getText().toString();
		int sYear, sDay, sMonth;
		
		sYear = Integer.parseInt(str.substring(0, 4));
		sMonth = Integer.parseInt(str.substring(5, 7)) -1;
		sDay = Integer.parseInt(str.substring(8, 10));
		
		DatePickerDialog dpd = new DatePickerDialog(context,
		        new DatePickerDialog.OnDateSetListener() {
		 
		            @Override
		            public void onDateSet(DatePicker view, int year,
		                    int monthOfYear, int dayOfMonth) {
		            	String months = "";
		            	String days = "";
		            	if(String.valueOf(monthOfYear + 1).length() == 1){
		            		months ="0"+(monthOfYear+1);
		            	}else{
		            		months = String.valueOf((monthOfYear+1));
		            	}
		            	
		            	if(String.valueOf(dayOfMonth).length() == 1){
		            		days ="0"+dayOfMonth;
		            	}else{
		            		days =String.valueOf(dayOfMonth);		            		
		            	}
		            	
		                sdateEdit.setText(year + "-"
		                        + months + "-" + days);
		 
		            }
		        }, sYear, sMonth, sDay);
		dpd.show();
		
	}
	
	private void eDateSetting(){
		String str = edateEdit.getText().toString();
		int eYear, eDay, eMonth;
		
		eYear = Integer.parseInt(str.substring(0, 4));
		eMonth = Integer.parseInt(str.substring(5, 7)) -1;
		eDay = Integer.parseInt(str.substring(8, 10));
		
		DatePickerDialog dpd = new DatePickerDialog(context,
		        new DatePickerDialog.OnDateSetListener() {
		 
		            @Override
		            public void onDateSet(DatePicker view, int year,
		                    int monthOfYear, int dayOfMonth) {
		            	String months = "";
		            	String days = "";
		            	
		            	if(String.valueOf(monthOfYear + 1).length() == 1){
		            		months ="0"+(monthOfYear+1);
		            	}else{
		            		months = String.valueOf((monthOfYear+1));
		            	}
		            	
		            	if(String.valueOf(dayOfMonth).length() == 1){
		            		days ="0"+dayOfMonth;
		            	}else{
		            		days =String.valueOf(dayOfMonth);		            		
		            	}
		            	
		                edateEdit.setText(year + "-"
		                        + months + "-" + days);
		            }
		        }, eYear, eMonth, eDay);
		dpd.show();
	}
	

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.footer01Btn:
			if(hdLinearLayout.getVisibility() == View.VISIBLE){
				myapp.setQuarantineState(true);
				searchState = true;
				
			}else if(hdLinearLayout.getVisibility() == View.GONE){
				myapp.setQuarantineState(false);
				searchState = false;
			}
			
			layoutHidden(searchState);
			break;
		case R.id.footer02Btn:	// 품목결과검색 화면 새창으로 띄움
			Intent intent = new Intent(getActivity().getApplication(), ProdSearchActivity.class);
			startActivity(intent);
			break;
		case R.id.footer03Btn:	// 검역대기 조회 화면으로 화면 전환
			QuarantineResultList incomeResultList = new QuarantineResultList();
			addFragmentReplace(R.id.base_frame, incomeResultList, QuarantineResultList.class.getName());
			break;
		case R.id.footer04Btn:	// 소독대기 조회 화면으로 화면 전환
			DisinfectionResultList disinfectionResultList = new DisinfectionResultList();
			addFragmentReplace(R.id.base_frame, disinfectionResultList, DisinfectionResultList.class.getName());			
			break;			
		case R.id.btn_oneday:
				searchDateBtn01.setBackgroundResource(R.drawable.btn_oneday_on);
				searchDateBtn03.setBackgroundResource(R.drawable.btn_threeday_off);
				searchDateBtn07.setBackgroundResource(R.drawable.btn_sevenday_off);
				sdateEdit.setText(BrUtilManager.getCurrentDateTime(1));
				edateEdit.setText(BrUtilManager.getCurrentDateTime(0));
			break;
		case R.id.btn_threeday:
				searchDateBtn01.setBackgroundResource(R.drawable.btn_oneday_off);
				searchDateBtn03.setBackgroundResource(R.drawable.btn_threeday_on);
				searchDateBtn07.setBackgroundResource(R.drawable.btn_sevenday_off);
				sdateEdit.setText(BrUtilManager.getCurrentDateTime(3));
				edateEdit.setText(BrUtilManager.getCurrentDateTime(0));				
			break;
		case R.id.btn_sevenday:
				searchDateBtn01.setBackgroundResource(R.drawable.btn_oneday_off);
				searchDateBtn03.setBackgroundResource(R.drawable.btn_threeday_off);
				searchDateBtn07.setBackgroundResource(R.drawable.btn_sevenday_on);
				sdateEdit.setText(BrUtilManager.getCurrentDateTime(7));
				edateEdit.setText(BrUtilManager.getCurrentDateTime(0));				
			break;
		case R.id.btn_s_calender:
				sDateSetting();
			break;
		case R.id.btn_e_calender:
				eDateSetting();
			break;			
		default:
			break;
		}
	}

	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {
		if (scrollState == SCROLL_STATE_IDLE){
			if(!pageState){
				if (listView.getLastVisiblePosition() >= listView.getCount()-1){
					if(nTotCnt - listView.getCount() > 0){
						pageState = true;
						mPageCnt ++;
						searchList();
						//myapp.utilm.showToast(context, "다음페이지로  = " + listView.getCount());					
					}else{
						myapp.utilm.showToast(context, "다음페이지 없음 ");
					}
				}				
			}
		}
	}

	@Override
	public void onScroll(AbsListView view, int firstVisibleItem,
			int visibleItemCount, int totalItemCount) {
		
	}

	@Override
	public void Onback() {
		if(myapp.isQuarantineState()){
		}else{
			layoutHidden(true);
			footerBtn01.setBackgroundResource(R.drawable.f_search_sel);
			myapp.setQuarantineState(false);
			searchState = true;
		}
	}
	
	@Override
	public void onPause() {
		layoutHidden(true);
		myapp.setQuarantineState(true);
		myapp.setFinishState(false);
		super.onPause();
	}
	
	@Override
	public void onResume() {
		if(myapp.isFinishState()){
			((Activity) context).finish();
			myapp.setFinishState(false);
		}
		if(myapp.isAbleHome()){
			homeBtn.performClick();
			myapp.setAbleHome(false);
		}
		super.onResume();
	}
	
	@Override
	public void onDestroyView() {
		super.onDestroyView();
		AppStatus.navigation.delPathLocation();
	}
	
	private void reesultToast() {
        am.runOnUiThread(new Runnable() {
			@Override
			public void run() {
				Toast toast = Toast.makeText(getActivity().getApplicationContext(), mResult, Toast.LENGTH_SHORT);
		        toast.setGravity(Gravity.CENTER, 0, 50);
		        toast.show();
			}
		});
    }

}